package com.zmcn.flowindex.fw.util;

public class ParseUtil {
	/**
	 * 去掉双引号以及里面的逗号
	 * 
	 * @param s
	 * @return
	 */
	private static String filterDot(String s) {
		int pos = -1;
		StringBuffer sb = new StringBuffer();
		boolean flag = true;
		while (-1 != (pos = s.indexOf("\""))) {
			flag = !flag;
			String t = s.substring(0, pos);
			if (flag) {
				t = t.replaceAll(",", "，");
			}
			sb.append(t);
			s = s.substring(pos + 1);
		}
		sb.append(s);
		return sb.toString();
	}

	/**
	 * 去掉双引号以及里面的逗号
	 * 
	 * @param s
	 * @return
	 */
	public static String[] splitByDot(String s) {
		s = filterDot(s);
		String[] ss = s.split(",");
		for (int i = 0; i < ss.length; i++) {
			ss[i] = ss[i].trim();
		}
		return ss;
	}

	/**
	 * 金额字符串元转整形分
	 * 
	 * @param s
	 * @return
	 */
	public static int formatMoney(String s) {
		return Integer.parseInt(s) * 100;
	}

	/**
	 * yyyy-MM-dd->yyyyMMdd
	 * 
	 * @param s
	 * @return
	 */
	public static String formatDate(String s) {
		return s.replaceAll("-", "");
	}
}
